<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>修改人员</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet"/>

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>

</head>
<body>
<div class="col-sm-12">
    <form class="form-horizontal m-t" id="form" method="post"
          action="${pageContext.request.contextPath}/admin/sysopt_update.action">
        <input type="hidden" name="sid" value="${user.sid}">
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>账号:</label>
            <div class="col-sm-8">
                <input class="form-control" readonly name="userName"  value="${user.userName}" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>姓名:</label>
            <div class="col-sm-8">
                <input class="form-control" name="uname" value="${user.uname}" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>密码:</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="password" readonly size="30" value="******"/>
                    <a class="input-group-addon" href="javascript:void(0);">修改</a>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label">手机:</label>
            <div class="col-sm-8">
                <input class="form-control" name="tel" size="30" value="${user.tel}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label">联系地址:</label>
            <div class="col-sm-8">
                <input class="form-control" name="addr" size="30" value="${user.addr}"/>
            </div>
        </div>
        <div class="form-group">
               <label class="col-sm-3  control-label"><i class="require">*</i>状态:</label>
            <div class="col-sm-8">
                <select name="status" id="status"  class="form-control">
                    <option value="1">激活</option>
                    <option value="0">禁止</option>
                </select>
            </div>
        </div>
        <c:if test="${userRole == 1}">
	        <div class="form-group">
	               <label class="col-sm-3  control-label"><i class="require">*</i>级别:</label>
	            <div class="col-sm-8">
	                <select name="rLevel" id="rLevel" class="form-control">
	                    <option value="5">区域主管</option>
	                    <option value="1">普通管理员</option>
	                </select>
	            </div>
	        </div>
        </c:if>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>权限设置:</label>
            <div class="col-sm-8">
                <select name="roles" id="roles" class="form-control" multiple="multiple"></select>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var selecteds = '${user.roles}';
        $.post("${pageContext.request.contextPath}/admin/role_list.action", function (data) {
            for (var i = 0; i < data.length; i++) {
                $("#roles").append("<option value='" + data[i].sid + "'>" + data[i].rName + "</option>");
            }
            selecteds = selecteds.split("|");
            for (var j=0;j<selecteds.length;j++) {
            	$("#roles  option[value='" + selecteds[j] + "'] ").attr("selected", true); 
            }

            $("#roles").select2({
            })
        }, "json");
        
        $("#roles").select2({
            minimumResultsForSearch: -1,
            placeholder: "选择角色",
            width: "100%"
        })
        
        $(".input-group-addon").click(function () {
            var $input = $(this).prev();
            $input.removeAttr("readonly");
            $input.attr("name", "passwd");
            $input.val("");
        });
        
        $("#status").val('${user.status}');
        $("#rLevel").val('${user.rLevel}');
    })
</script>
</body>
</html>
